package theOrbalEra.common.item;

import theOrbalEra.common.TheOrbalEra;
import theOrbalEra.common.util.DefultValue;
import theOrbalEra.common.util.Element;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;


public class OrbalItemElement extends OrbalItem {
	public int ele;
	
	public Icon water;
	public Icon earth;
	public Icon wind;
	public Icon time;
	public Icon space;
	public Icon unreal;

	public OrbalItemElement(int par1, int par2) {
		super(par1);
		ele = par2;
	
	}
	 @Override
		@SideOnly(Side.CLIENT)
		public Icon getIconFromDamage(int par1) {
			switch (ele) {
			case Element.Fire:
				return itemIcon;
			case Element.Water:
				return this.water;
			case Element.Earth:
				return this.earth;
			case Element.Wind:
				return this.wind;
			case Element.Time:
				return this.time;
			case Element.Space:
				return this.space;
			case Element.Unreal:
				return this.unreal;

			default:
				return itemIcon;

			}
		}
	    @Override
		@SideOnly(Side.CLIENT)
		public void registerIcons(IconRegister par1IconRegister) {
			this.itemIcon=par1IconRegister.registerIcon(DefultValue.ModName+":fireElement");
			this.water=par1IconRegister.registerIcon(DefultValue.ModName+":waterElement");
			this.earth=par1IconRegister.registerIcon(DefultValue.ModName+":earthElement");
			this.wind=par1IconRegister.registerIcon(DefultValue.ModName+":windElement");
			this.time=par1IconRegister.registerIcon(DefultValue.ModName+":timeElement");
			this.space=par1IconRegister.registerIcon(DefultValue.ModName+":spaceElement");
			this.unreal=par1IconRegister.registerIcon(DefultValue.ModName+":unrealElement");
		}
		public static int[] eleInInventory(EntityPlayer player) {
			int[] ele={0,0,0,0,0,0,0};
		
			for(int i=0;i<player.inventory.mainInventory.length;i++){
				ItemStack stack=player.inventory.mainInventory[i];
				if(stack!=null)
				if(stack.getItem() instanceof OrbalItemElement){
				if(stack.itemID==TheOrbalEra.fireElementId+256)
						ele[0]+=stack.stackSize;
				else if(stack.itemID==TheOrbalEra.waterElementId+256)
					ele[1]+=stack.stackSize;
				else if(stack.itemID==TheOrbalEra.earthElementId+256)
					ele[2]+=stack.stackSize;
				else if(stack.itemID==TheOrbalEra.windElementId+256)
					ele[3]+=stack.stackSize;
				else if(stack.itemID==TheOrbalEra.timeElementId+256)
					ele[4]+=stack.stackSize;
				else if(stack.itemID==TheOrbalEra.spaceElementId+256)
					ele[5]+=stack.stackSize;
				else if(stack.itemID==TheOrbalEra.unrealElementId+256)
					ele[6]+=stack.stackSize;
				
					
				}
			}
			return ele;
		}

		

		
	

}
